#include "Nano100Series.h"
#include "Timer1.h"

static int is_trigger = 0;

void Timer1Open(void)
{
    TIMER_Open(TIMER1, TIMER_PERIODIC_MODE, 60);
    TIMER_EnableInt(TIMER1);
    NVIC_EnableIRQ(TMR1_IRQn);
    TIMER_Start(TIMER1);
}

void Timer1Close(void)
{
	TIMER_Stop(TIMER1);
	NVIC_DisableIRQ(TMR1_IRQn);
	TIMER_DisableInt(TIMER1);
	TIMER_Close(TIMER1);
}

int Timer1IsTrigger(void)
{
	return is_trigger;
}

void Timer1ResetFlag(void)
{
	is_trigger = 0;
}

void TMR1_IRQHandler(void)
{
	is_trigger = 1;
    TIMER_ClearIntFlag(TIMER1);
}
